package com.springcloud.controller;

import com.springcloud.AccessLimiter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 顾志杰
 * @date 2021/5/31-11:24
 */
@RestController
@Slf4j
public class Controller {

    @Autowired
    private AccessLimiter accessLimiter;

    @GetMapping("test")
    public String test(){
        accessLimiter.limiterAccess("ratelimiter-test",1);
        return "success";
    }

    // 注意配置扫包路径
    @GetMapping("testAnnotation")
    @com.springcloud.annotation.AccessLimiter(limit = 1)
    public String testAnnotation(){
        return "success";
    }
}
